.class public Lcom/bitauto/autoeasy/tool/Caller;
.super Ljava/lang/Object;
.source "Caller.java"


# static fields
.field private static TAG:Ljava/lang/String;

.field private static requestCache:Lcom/bitauto/autoeasy/tool/RequestCache;


# direct methods
.method static constructor <clinit>()V
    .locals 1

    .prologue
    .line 44
    const/4 v0, 0x0

    sput-object v0, Lcom/bitauto/autoeasy/tool/Caller;->requestCache:Lcom/bitauto/autoeasy/tool/RequestCache;

    .line 46
    const-string v0, "Caller"

    sput-object v0, Lcom/bitauto/autoeasy/tool/Caller;->TAG:Ljava/lang/String;

    .line 39
    return-void
.end method

.method public constructor <init>()V
    .locals 0

    .prologue
    .line 39
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    return-void
.end method

.method private static convertStreamToString(Ljava/io/InputStream;)Ljava/lang/String;
    .locals 6
    .parameter "is"

    .prologue
    .line 109
    new-instance v2, Ljava/io/BufferedReader;

    new-instance v4, Ljava/io/InputStreamReader;

    invoke-direct {v4, p0}, Ljava/io/InputStreamReader;-><init>(Ljava/io/InputStream;)V

    invoke-direct {v2, v4}, Ljava/io/BufferedReader;-><init>(Ljava/io/Reader;)V

    .line 110
    .local v2, reader:Ljava/io/BufferedReader;
    new-instance v3, Ljava/lang/StringBuilder;

    invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V

    .line 112
    .local v3, sb:Ljava/lang/StringBuilder;
    const/4 v1, 0x0

    .line 114
    .local v1, line:Ljava/lang/String;
    :goto_0
    :try_start_0
    invoke-virtual {v2}, Ljava/io/BufferedReader;->readLine()Ljava/lang/String;
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0

    move-result-object v1

    if-nez v1, :cond_0

    .line 121
    :try_start_1
    invoke-virtual {p0}, Ljava/io/InputStream;->close()V
    :try_end_1
    .catch Ljava/io/IOException; {:try_start_1 .. :try_end_1} :catch_3

    .line 127
    :goto_1
    invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v4

    return-object v4

    .line 115
    :cond_0
    :try_start_2
    new-instance v4, Ljava/lang/StringBuilder;

    invoke-static {v1}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v5

    invoke-direct {v4, v5}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v5, "\n"

    invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v4

    invoke-virtual {v4}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v4

    invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_0
    .catch Ljava/io/IOException; {:try_start_2 .. :try_end_2} :catch_0

    goto :goto_0

    .line 117
    :catch_0
    move-exception v4

    move-object v0, v4

    .line 118
    .local v0, e:Ljava/io/IOException;
    :try_start_3
    invoke-virtual {v0}, Ljava/io/IOException;->printStackTrace()V
    :try_end_3
    .catchall {:try_start_3 .. :try_end_3} :catchall_0

    .line 121
    :try_start_4
    invoke-virtual {p0}, Ljava/io/InputStream;->close()V
    :try_end_4
    .catch Ljava/io/IOException; {:try_start_4 .. :try_end_4} :catch_1

    goto :goto_1

    .line 122
    :catch_1
    move-exception v0

    .line 123
    invoke-virtual {v0}, Ljava/io/IOException;->printStackTrace()V

    goto :goto_1

    .line 119
    .end local v0           #e:Ljava/io/IOException;
    :catchall_0
    move-exception v4

    .line 121
    :try_start_5
    invoke-virtual {p0}, Ljava/io/InputStream;->close()V
    :try_end_5
    .catch Ljava/io/IOException; {:try_start_5 .. :try_end_5} :catch_2

    .line 125
    :goto_2
    throw v4

    .line 122
    :catch_2
    move-exception v0

    .line 123
    .restart local v0       #e:Ljava/io/IOException;
    invoke-virtual {v0}, Ljava/io/IOException;->printStackTrace()V

    goto :goto_2

    .line 122
    .end local v0           #e:Ljava/io/IOException;
    :catch_3
    move-exception v0

    .line 123
    .restart local v0       #e:Ljava/io/IOException;
    invoke-virtual {v0}, Ljava/io/IOException;->printStackTrace()V

    goto :goto_1
.end method

.method public static createStringFromIds([I)Ljava/lang/String;
    .locals 6
    .parameter "ids"

    .prologue
    .line 135
    if-nez p0, :cond_0

    .line 136
    const-string v2, ""

    .line 144
    :goto_0
    return-object v2

    .line 138
    :cond_0
    const-string v1, ""

    .line 140
    .local v1, query:Ljava/lang/String;
    array-length v2, p0

    const/4 v3, 0x0

    :goto_1
    if-lt v3, v2, :cond_1

    move-object v2, v1

    .line 144
    goto :goto_0

    .line 140
    :cond_1
    aget v0, p0, v3

    .line 141
    .local v0, id:I
    new-instance v4, Ljava/lang/StringBuilder;

    invoke-static {v1}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v5

    invoke-direct {v4, v5}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v4, v0}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v4

    const-string v5, "+"

    invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v4

    invoke-virtual {v4}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    .line 140
    add-int/lit8 v3, v3, 0x1

    goto :goto_1
.end method

.method public static doGet(Ljava/lang/String;)Ljava/lang/String;
    .locals 12
    .parameter "url"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Lcom/bitauto/autoeasy/tool/WSError;
        }
    .end annotation

    .prologue
    .line 57
    const/4 v0, 0x0

    .line 58
    .local v0, data:Ljava/lang/String;
    sget-object v9, Lcom/bitauto/autoeasy/tool/Caller;->requestCache:Lcom/bitauto/autoeasy/tool/RequestCache;

    if-eqz v9, :cond_0

    .line 59
    sget-object v9, Lcom/bitauto/autoeasy/tool/Caller;->requestCache:Lcom/bitauto/autoeasy/tool/RequestCache;

    invoke-virtual {v9, p0}, Lcom/bitauto/autoeasy/tool/RequestCache;->get(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    .line 60
    if-eqz v0, :cond_0

    .line 61
    sget-object v9, Lcom/bitauto/autoeasy/tool/Caller;->TAG:Ljava/lang/String;

    new-instance v10, Ljava/lang/StringBuilder;

    const-string v11, "Caller.doGet [cached] "

    invoke-direct {v10, v11}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v10, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v10

    invoke-virtual {v10}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v10

    invoke-static {v9, v10}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    move-object v1, v0

    .line 104
    .end local v0           #data:Ljava/lang/String;
    .local v1, data:Ljava/lang/String;
    :goto_0
    return-object v1

    .line 67
    .end local v1           #data:Ljava/lang/String;
    .restart local v0       #data:Ljava/lang/String;
    :cond_0
    new-instance v3, Lorg/apache/http/impl/client/DefaultHttpClient;

    invoke-direct {v3}, Lorg/apache/http/impl/client/DefaultHttpClient;-><init>()V

    .line 68
    .local v3, httpClient:Lorg/apache/http/client/HttpClient;
    new-instance v5, Lorg/apache/http/client/methods/HttpGet;

    invoke-direct {v5, p0}, Lorg/apache/http/client/methods/HttpGet;-><init>(Ljava/lang/String;)V

    .line 74
    .local v5, httpGet:Lorg/apache/http/client/methods/HttpGet;
    :try_start_0
    invoke-interface {v3, v5}, Lorg/apache/http/client/HttpClient;->execute(Lorg/apache/http/client/methods/HttpUriRequest;)Lorg/apache/http/HttpResponse;
    :try_end_0
    .catch Ljava/net/UnknownHostException; {:try_start_0 .. :try_end_0} :catch_0
    .catch Ljava/net/SocketException; {:try_start_0 .. :try_end_0} :catch_2
    .catch Lorg/apache/http/client/ClientProtocolException; {:try_start_0 .. :try_end_0} :catch_1
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_3

    move-result-object v6

    .line 86
    .local v6, httpResponse:Lorg/apache/http/HttpResponse;
    :try_start_1
    invoke-interface {v6}, Lorg/apache/http/HttpResponse;->getEntity()Lorg/apache/http/HttpEntity;

    move-result-object v4

    .line 88
    .local v4, httpEntity:Lorg/apache/http/HttpEntity;
    if-eqz v4, :cond_1

    .line 89
    invoke-interface {v4}, Lorg/apache/http/HttpEntity;->getContent()Ljava/io/InputStream;

    move-result-object v7

    .line 90
    .local v7, inputStream:Ljava/io/InputStream;
    invoke-static {v7}, Lcom/bitauto/autoeasy/tool/Caller;->convertStreamToString(Ljava/io/InputStream;)Ljava/lang/String;

    move-result-object v0

    .line 92
    sget-object v9, Lcom/bitauto/autoeasy/tool/Caller;->requestCache:Lcom/bitauto/autoeasy/tool/RequestCache;

    if-eqz v9, :cond_1

    .line 93
    sget-object v9, Lcom/bitauto/autoeasy/tool/Caller;->requestCache:Lcom/bitauto/autoeasy/tool/RequestCache;

    invoke-virtual {v9, p0, v0}, Lcom/bitauto/autoeasy/tool/RequestCache;->put(Ljava/lang/String;Ljava/lang/String;)V
    :try_end_1
    .catch Lorg/apache/http/client/ClientProtocolException; {:try_start_1 .. :try_end_1} :catch_1
    .catch Ljava/io/IOException; {:try_start_1 .. :try_end_1} :catch_3

    .line 103
    .end local v4           #httpEntity:Lorg/apache/http/HttpEntity;
    .end local v6           #httpResponse:Lorg/apache/http/HttpResponse;
    .end local v7           #inputStream:Ljava/io/InputStream;
    :cond_1
    :goto_1
    sget-object v9, Lcom/bitauto/autoeasy/tool/Caller;->TAG:Ljava/lang/String;

    new-instance v10, Ljava/lang/StringBuilder;

    const-string v11, "Caller.doGet "

    invoke-direct {v10, v11}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v10, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v10

    invoke-virtual {v10}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v10

    invoke-static {v9, v10}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    move-object v1, v0

    .line 104
    .end local v0           #data:Ljava/lang/String;
    .restart local v1       #data:Ljava/lang/String;
    goto :goto_0

    .line 75
    .end local v1           #data:Ljava/lang/String;
    .restart local v0       #data:Ljava/lang/String;
    :catch_0
    move-exception v2

    .line 76
    .local v2, e:Ljava/net/UnknownHostException;
    :try_start_2
    new-instance v8, Lcom/bitauto/autoeasy/tool/WSError;

    invoke-direct {v8}, Lcom/bitauto/autoeasy/tool/WSError;-><init>()V

    .line 77
    .local v8, wsError:Lcom/bitauto/autoeasy/tool/WSError;
    invoke-virtual {v2}, Ljava/net/UnknownHostException;->getLocalizedMessage()Ljava/lang/String;

    move-result-object v9

    invoke-virtual {v8, v9}, Lcom/bitauto/autoeasy/tool/WSError;->setMessage(Ljava/lang/String;)V

    .line 78
    throw v8
    :try_end_2
    .catch Lorg/apache/http/client/ClientProtocolException; {:try_start_2 .. :try_end_2} :catch_1
    .catch Ljava/io/IOException; {:try_start_2 .. :try_end_2} :catch_3

    .line 97
    .end local v2           #e:Ljava/net/UnknownHostException;
    .end local v8           #wsError:Lcom/bitauto/autoeasy/tool/WSError;
    :catch_1
    move-exception v9

    move-object v2, v9

    .line 98
    .local v2, e:Lorg/apache/http/client/ClientProtocolException;
    invoke-virtual {v2}, Lorg/apache/http/client/ClientProtocolException;->printStackTrace()V

    goto :goto_1

    .line 79
    .end local v2           #e:Lorg/apache/http/client/ClientProtocolException;
    :catch_2
    move-exception v2

    .line 80
    .local v2, e:Ljava/net/SocketException;
    :try_start_3
    new-instance v8, Lcom/bitauto/autoeasy/tool/WSError;

    invoke-direct {v8}, Lcom/bitauto/autoeasy/tool/WSError;-><init>()V

    .line 81
    .restart local v8       #wsError:Lcom/bitauto/autoeasy/tool/WSError;
    invoke-virtual {v2}, Ljava/net/SocketException;->getLocalizedMessage()Ljava/lang/String;

    move-result-object v9

    invoke-virtual {v8, v9}, Lcom/bitauto/autoeasy/tool/WSError;->setMessage(Ljava/lang/String;)V

    .line 82
    throw v8
    :try_end_3
    .catch Lorg/apache/http/client/ClientProtocolException; {:try_start_3 .. :try_end_3} :catch_1
    .catch Ljava/io/IOException; {:try_start_3 .. :try_end_3} :catch_3

    .line 99
    .end local v2           #e:Ljava/net/SocketException;
    .end local v8           #wsError:Lcom/bitauto/autoeasy/tool/WSError;
    :catch_3
    move-exception v9

    move-object v2, v9

    .line 100
    .local v2, e:Ljava/io/IOException;
    invoke-virtual {v2}, Ljava/io/IOException;->printStackTrace()V

    goto :goto_1
.end method

.method public static setRequestCache(Lcom/bitauto/autoeasy/tool/RequestCache;)V
    .locals 0
    .parameter "requestCache"

    .prologue
    .line 131
    sput-object p0, Lcom/bitauto/autoeasy/tool/Caller;->requestCache:Lcom/bitauto/autoeasy/tool/RequestCache;

    .line 132
    return-void
.end method
